<template>
  <div>
    <TopNav title="我的跟帖" />
    <div class="item" v-for="comment in commentList" :key="comment.id">
      <div class="date">2019-10-10 10:25</div>
      <div class="parent" v-if="comment.parent">
        <div class="name">
          回复：{{
            comment.parent.user.nickname || comment.parent.user.username
          }}
        </div>
        <div class="content">{{ comment.parent.content }}</div>
      </div>
      <div class="mainContent">{{ comment.content }}</div>
      <div class="post" v-if="comment.post">原文：{{ comment.post.title }}</div>
      <div v-else class="post">该帖已被删除</div>
    </div>
  </div>
</template>

<script>
import TopNav from "../../components/TopNav";
export default {
  data() {
    return {
      commentList: "",
    };
  },
  components: {
    TopNav,
  },
  created() {
    this.$axios({
      url: "/user_comments",
    }).then((res) => {
      console.log(res.data);
      this.commentList = res.data.data;
    });
  },
};
</script>

<style lang="less" scoped>
.item {
  padding: 14/360 * 100vw;
  border-bottom: 1px solid #ccc;
  .date {
    font-size: 14/360 * 100vw;
    color: #888;
  }
  .parent {
    background-color: #e4e4e4;
    margin: 16/360 * 100vw 0;
    padding: 14/360 * 100vw 6/360 * 100vw;
    color: #888;
    .name {
      font-size: 12/360 * 100vw;
    }
    .content {
      font-size: 16/360 * 100vw;
      margin-top: 8/360 * 100vw;
    }
  }
  .mainContent {
    font-size: 18/360 * 100vw;
    color: #333;
  }
  .post {
    font-size: 14/360 * 100vw;
    color: #888;
    margin-top: 16/360 * 100vw;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
}
</style>